package com.mrlv.ht.service.impl;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.mrlv.ht.mapper.UserInfoMapper;
import com.mrlv.ht.mapper.UserMapper;
import com.mrlv.ht.pojo.User;
import com.mrlv.ht.pojo.UserExample;
import com.mrlv.ht.pojo.UserInfo;
import com.mrlv.ht.service.IUserService;

@Service("userService")
public class UserServiceImpl implements IUserService {

	@Resource
	private UserMapper userMapper;
	
	@Resource
	private UserInfoMapper userInfoMapper;
	
	@Override
	public int insert(User user, UserInfo userInfo) {
		user.setUserId(UUID.randomUUID().toString());
		user.setState(new BigDecimal(1));
		user.setCreateTime(new Date());
		user.setUpdateTime(user.getCreateTime());
		
		userInfo.setUserInfoId(user.getUserId());
		userInfo.setCreateTime(user.getCreateTime());
		userInfo.setUpdateTime(user.getUpdateTime());
		
		int a = userMapper.insertSelective(user);
		int b = userInfoMapper.insertSelective(userInfo);
		
		return a+b;
	}

	@Override
	public List<User> selectByExample(UserExample example) {
		return userMapper.selectByExample(example);
	}

	@Override
	public User selectByPrimaryKey(String userId) {
		return null;
	}

	@Override
	public int updateByPrimaryKeySelective(User record) {
		return userMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public List<User> findAllUser() {
		return userMapper.findAllUser();
	}

	@Override
	public int deleteBatch(String[] userId) {
		return userMapper.deleteBatch(userId);
	}

	@Override
	public int deleteUserBatch(String[] userId) {
		return userMapper.deleteUserBatch(userId);
	}

	@Override
	public int updateBatch1(String[] userId) {
		return userMapper.updateBatch1(userId);
	}

	@Override
	public int updateBatch0(String[] userId) {
		return userMapper.updateBatch0(userId);
	}

	@Override
	public User findModule(String username) {
		return userMapper.findModule(username);
	}

}
